.\" @configure_input@
.\"
.\" neo4j-client - command shell for Neo4j
.\" Copyright 2016 Chris Leishman (http://github.com/cleishm)
.\"
.\" Licensed under the Apache License, Version 2.0 (the "License");
.\" you may not use this file except in compliance with the License.
.\" You may obtain a copy of the License at
.\"
.\"     http://www.apache.org/licenses/LICENSE-2.0
.\"
.\" Unless required by applicable law or agreed to in writing, software
.\" distributed under the License is distributed on an "AS IS" BASIS,
.\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.\" See the License for the specific language governing permissions and
.\" limitations under the License.
.\"
.TH NEO4J-CLIENT 1
.SH NAME
neo4j\-client \- command shell for Neo4j
.SH SYNOPSIS
.B neo4j\-client \fI[options...] [URL | host[:port]]\fR
.SH "DESCRIPTION"
\fBneo4j\-client\fR is a command shell for Neo4j. It supports secure
connections to Neo4j server, sending of statements (including multiline
statements), persistent command history, and rendering of results to tables or
CSV.

\fBneo4j\-client\fR requires Neo4j Server version 3.0 or later.
.SH OPTIONS
.TP
.I \-\-help, \-h
Display a brief help listing.
.TP
.I \-\-history=file
Use the specified file for saving history.

By default, history is saved to \fI$(HOME)/.neo4j/client-history\fR.
.TP
.I \-\-no-history
Do not save the command history.
.TP
.I \-\-colorize
Enable colorization of output and errors using ANSI escape sequences.
.TP
.I \-\-no-colorize
Disable colorization of output and errors even when connected to a TTY.
.TP
.I \-\-ca\-file=cert.pem
Specify a file containing trusted certificates (and CRLs). The file should
contain one or more certificates in PEM format.
.TP
.I \-\-ca\-directory=dir
Specify a directory containing trusted certificates (and CRLs). The
certificates should have names of the form: hash.0 or have symbolic links to
them of this form ("hash" is the hashed certificate subject name: see the -hash
option of the x509 utility). Under Unix the c_rehash script will automatically
create symbolic links to a directory of certificates.
.TP
.I \-\-insecure
Do not attempt to establish a secure (TLS) connection to Neo4j.
.TP
.I \-\-non-interactive
Use non-interactive (batch) mode and do not prompt for credentials when
connecting.
.TP
.I \-\-username=name, \-u name
Use the specified username when connecting.

The username (and password) can also be supplied in the connection URL, and will
override what is set here.
.TP
.I \-\-password=pass, \-p pass
Use the specified password when connecting.

The password (and username) can also be supplied in the connection URL, and will
override what is set here.
.TP
.I \-P
Prompt for a password, even in non-interactive (batch) mode. This option
requires that neo4j-client is being run with a controlling TTY, which will
be used for password prompting and input.
.TP
.I \-\-known-hosts=file
When using secure (TLS) connections, the certificate signatures of previously
verified hosts is persisted to the known hosts file. This setting specifies
the location of that file.

By default, the file is \fI$(HOME)/.neo4j/neo4j_known_certs\fR.
.TP
.I \-\-no-known-hosts
Do not do host checking via known-hosts (use only TLS certificate verification).
.TP
.I \-\-output file, \-o file
Redirect output to the specified file. Must be specified in conjunction with
\fI--source\fR/\fI-i\fR, and may be specified multiple times.
.TP
.I \-\-source file, \-i file
Evaluate statements from the specified file. May be specified multiple times.
.TP
.I \-\-eval script, \-e script
Evaluate the argument string. May be specified multiple times.
.TP
.I \-\-verbose, \-v
Increase the logging verbosity. Each use increases the verbosity. Each
verbosity level roughly equates to logging of warnings, general information,
debug output and trace information.
.TP
.I \-\-version
Print the neo4j\-client version and exit.
.SH URL
A URL may be specified on the command line, and will cause \fBneo4j\-client\fR
to attempt to connect to the specified server immediately. The URL is of the
form \fIneo4j://host[:port]\fR, and specifies the host and port the Neo4j
server is listening on.
.SH INTERACTIVE MODE
When \fBneo4j\-client\fR is started with standard input connected to an
interactive terminal, it will run in interactive mode. This will present a
command prompt to the user and will evaluate each command as it is entered. The
history of entered commands will be saved (unless disabled) and an errors in
evaluation will be presented to the user. Results from statements sent to Neo4j
will be presented to the user in table format (by default), using the full
width of the terminal.
.SH NON-INTERACTIVE (BATCH) MODE
When \fBneo4j\-client\fR is started with standard intput connected to a pipe,
or when the \fI--source\fR/\fI-i\fR argument is specified, statements will be
read from the pipe or the specified file(s).  Any error in evaluation will
cause \fBneo4j\-client\fR to terminate without evaluating any further input.
By default, results will be output in CSV format, although this may be
changed using \fI:set format=(csv|table)\fR.
.SH USAGE
Once started, commands and statements can be entered at the \fBneo4j\-client\fR
prompt. Commands always begin with a colon (:) and conclude at the end of the
line, e.g. \fI:help\fR, and are evaluated by \fBneo4j\-client\fR rather than
being sent to the Neo4j server. Statements do not begin with a colon (:), may
span multiple lines, are terminated with a semi-colon (;) and will be sent to
the Neo4j server for evaluation.
.SH COMMANDS
\fBneo4j\-client\fR understands a variety of commands, including:
.TP
.I :help
List all the available commands and usage information.
.TP
.I ":quit \fR(or \fI:exit\fR)\fI"
Exit \fBneo4j\-client\fR.
.TP
.I ":connect '<url>'"
Connect to the Neo4j server specified by the URL. Note that the URL must be
given in quotes, as the \fI//\fR characters in the URL would otherwise
be considered as the start of a comment.
.TP
.I ":connect <host>[:<port>]"
Connect to the Neo4j server specified by the host and optional port.
.TP
.I :disconnect
Disconnect from the Neo4j server (if connected).
.TP
.I :export [name=val] ...
Export parameters for queries. The parameter will be available in queries
as \fI{name}\fR, and will be a string containing the text specified. Values
containing spaces must be quoted, e.g. \fI:export name="foo bar"\fR. Multiple
name and value pairs may be specified. If no name and value pairs are specified,
then the list of currently exported values will be displayed.

Note that all parameters are sent to the server for every query, so it is
best not to export large values without immediately using \fI:unexport\fR
after.
.TP
.I :unexport name ...
Remove a named parameter from those exported to queries.
.TP
.I :reset
Reset the session with the server, aborting any open transactions.
.TP
.I :set [option=value] ...
Set various shell options. If no option name and value paris are specified,
then the list of current options and their values will be displayed.
.TP
.I :source <file>
Read and evaluate commands and statements in the specified file. Evaluation
will stop if any error is encountered.
.TP
.I :status
Show the client connection status, which indicates if the client is
disconnected or connected to a server. If the latter, the connection URI is
output.
.TP
.I :schema
Show database schema indexes and constraints.
.TP
.I ":format (table|csv)"
Set the output format to either table or CSV.

Equivalent to `:set format=(table|csv)`.
.TP
.I ":width <n>"
Set the output width for table rendering. \fIn\fR is either an integer between
2 and 4095, or "auto". In interactive mode, the default is "auto",
which sets the output width to match the width of the terminal (or to 70
characters if the output is not a terminal).

Equivalent to `:set width=<n>`.
.SH EXAMPLES
Start \fBneo4j\-client\fR in interactive mode, and run a query:

    $ neo4j-client -u neo4j localhost
    Password: *****
    neo4j> MATCH (n:Person) RETURN n.name, n.born LIMIT 4;
    +-----------------------------+-----------------------------+
    | n.name                      | n.born                      |
    +-----------------------------+-----------------------------+
    | Keanu Reeves                | 1964                        |
    | Carrie-Anne Moss            | 1967                        |
    | Laurence Fishburne          | 1961                        |
    | Hugo Weaving                | 1960                        |
    +-----------------------------+-----------------------------+
    neo4j> :quit
    $

Evaluate a query in non-interactive (batch) mode, saving the output to a csv
file:

    $ echo "MATCH (n:Person) RETURN n.name, n.born LIMIT 4;" | \\
            neo4j\-client -u neo4j -P localhost > result.csv
    Password: *****
    $
    $ cat result.csv
    "n.name","n.born"
    "Keanu Reeves",1964
    "Carrie-Anne Moss",1967
    "Laurence Fishburne",1961
    "Hugo Weaving",1960
    $

Evaluate a source file, and save the output:

    $ neo4j\-client -u neo4j -p pass -o result.csv -i query.cyp
    $
    $ cat query.cyp
    MATCH (n:Person) RETURN n.name, n.born LIMIT 4;
    $
    $ cat result.csv
    "n.name","n.born"
    "Keanu Reeves",1964
    "Carrie-Anne Moss",1967
    "Laurence Fishburne",1961
    "Hugo Weaving",1960
    $

.SH ERRORS
In interactive mode, \fBneo4j\-client\fR attempts to exit cleanly (with
\fI$?\fR set to 0) when the session is terminated via the use of \fI:quit\fR,
\fI:exit\fR or \fIctrl-D\fR, and to use a non-zero exit code otherwise.
In non-interactive (batch) mode, \fBneo4j\-client\fR will exit cleanly if all
statements read from stdin evaluate successfully.
.SH VERSION
This man page is current for version @VERSION@ of neo4j\-client.
.SH COPYRIGHT
http://www.apache.org/licenses/LICENSE\-2.0
.SH AUTHORS
Chris Leishman (http://github.com/cleishm)
